import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import './assets/css/global.css'
import axios from 'axios'
import echarts from 'echarts'
import lodash from 'lodash'
import VueIntro from 'vue-introjs'
import VueQuillEditor from 'vue-quill-editor'
import mavonEditor from 'mavon-editor'
import 'mavon-editor/dist/css/index.css'
import i18n from './lang/index'
import 'fullpage.js/vendors/scrolloverflow'
import VueFullPage from 'vue-fullpage.js/dist/vue-fullpage.js'
import nprogress from 'nprogress'
import Lazyload from 'vue-lazyload'
import VideoPlayer from 'vue-video-player'
Vue.use(VideoPlayer)

Vue.config.productionTip = false

Vue.use(VueFullPage)
Vue.use(Lazyload, {
  loading: require('@/assets/load.jpg'),
  preload: 1
})
axios.defaults.baseURL = 'http://localhost/backstage/'
axios.interceptors.request.use(req => {
  req.headers['Content-Type'] = 'application/x-www-form-urlencoded'
  nprogress.start()
  return req
})
axios.interceptors.response.use(res => {
  nprogress.done()
  return res
})

function resize(x) {
  window.addEventListener('resize', function() {
    for(let i = 0; i < x.length; i++) {
      x[i].resize()
    }
  })
}
Vue.prototype.$resize = resize
axios.interceptors.response.use(response => {
  return response.data
})
Vue.prototype.$http = axios
Vue.prototype.$ecs = echarts
Vue.prototype._ = lodash
Vue.use(VueIntro)
Vue.use(VueQuillEditor)
Vue.use(mavonEditor)

Vue.config.errorHandler = (err, vm, info) => {
  console.error(err)
}

new Vue({
  router,
  store,
  i18n,
  render: h => h(App)
}).$mount('#app')
